package main
import(
	"fmt"
	"math/rand"
	"time"
)

func main(){
	test4()
}
//遍历A-Z
func test1(){
	var arr [26]byte
	for i := 0 ;i < 26;i++{
		arr[i] = 'A' + byte(i)
	}
	for _,v := range(arr){
		fmt.Printf("%c ", v)
	}
}
//数组最大值
func test2(){
	arr := [...]int{22,33,11,56,12,99,6,87}
	var max int = arr[0]
	var index int
	for i,v := range(arr){
		if i == 0 {
			continue
		}
		if(v > max){
			max = v
			index = i
		}
	}
	fmt.Println(max)
	fmt.Println(index)
}
//数组和 平均值
func test3(){
	var arr [8]int = [8]int{22,33,11,56,12,99,6,87}
	var sum int
	var avg float64
	for _,v := range(arr){
		sum += v
	}
	avg = float64(sum) / float64(len(arr))
	fmt.Println(avg)
	fmt.Println(sum)
}

func test4(){
	rand.Seed(time.Now().UnixNano())
	var arr [5]int
	fmt.Println(arr)
	for i,_ := range(arr){
		arr[i] = rand.Intn(100)
		fmt.Printf("%d ",arr[i])
		defer fmt.Printf("%d ",arr[i])
	}
	fmt.Println("")
}